package com.itheima.youdianda.controller;

import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.YddLink;
import com.itheima.youdianda.service.YddLinkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 链接管理
 */
@RestController
@Slf4j
@RequestMapping("ydd_link")
public class YddLinkController {
    @Autowired
    private YddLinkService service;

    /**
     * 友情链接详情
     *
     * @param id
     * @return
     */
    @GetMapping("rowInfo")
    public R rowInfo(Integer id) {
        return service.rowInfo(id);
    }

    /**
     * 友情链接修改
     *
     * @param yddLink
     * @return
     */
    @PostMapping("update")
    public R yddLinkUpdate(@RequestBody YddLink yddLink) {
        return service.yddLinkUpdate(yddLink);
    }

    /**
     * 友情链接添加
     *
     * @param yddLink
     * @return
     */
    @PostMapping("add")
    public R yddLinkAdd(@RequestBody YddLink yddLink) {
        return service.yddLinkAdd(yddLink);
    }

    /**
     * 友情链接列表
     *
     * @param page
     * @param limit
     * @param type
     * @return
     */
    @GetMapping("list")
    public R yddLinkList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                         @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit,
                         String type) {
        return service.yddLinkList(page, limit, type);
    }

    /**
     * 友情链接删除
     *
     * @param id
     * @return
     */
    @GetMapping("del")
    public R del(Integer id) {
        return service.del(id);
    }
}
